package fun.tan90.easy.binlog.manager.rest;

import fun.tan90.easy.binlog.base.convention.Res;
import fun.tan90.easy.binlog.manager.model.BinlogWorkInstance;
import fun.tan90.easy.binlog.manager.service.BinlogWorkerService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 控制层。
 *
 * @author 陈浩杰
 * @since 2023-09-01
 */
@RestController
@RequestMapping("/binlog-worker")
public class BinlogWorkController {

    @Resource
    BinlogWorkerService binlogWorkerService;

    /**
     * 在线工作节点列表
     *
     * @return
     */
    @GetMapping("online")
    public Res<List<BinlogWorkInstance>> onlineNodes() {
        return Res.ok(binlogWorkerService.onlineWorkers());
    }
}
